{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "_macros.html" as macros %}
{% import "_my_wtf_macros.html" as my_wtf_macros %}
{% import "user/partial/user_table.html" as user_table_macro %}

{% block title %}万屏时代OPC--拉新工程商列表七月数据{% endblock %}

{% block panel_heading %}
  万屏时代OPC--拉新工程商列表七月数据
{% endblock %}

{% block panel_body %}
    <form id="search-user-form" action="{{ url_for('op_bp.invite_users', list_key='July') }}"
          method="post" class="form" role="form">
        {{ my_wtf_macros.form_field(form.send_date_begin, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.send_date_end, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.is_bind, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.status, div_col=4, label_col=4, field_col=7) }}
        <div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
        <div class="pull-right btn-group">
            <button type="submit" class="btn btn-info"
                    id="query-demand-btn">
                查询
            </button>
            {% if not current_user.is_agent %}
                <a
                        href="javascript:void(0);"
                        target="_blank"
                        class="btn-group btn btn-primary"
                        id="export-user-info"
                >
                    导出
                </a>
            {% endif %}
        </div>
    </form>

    {% if pagination %}
    <div class="pagination">
        {{ macros.pagination_widget(pagination, 'op_bp.invite_users', list_key='July', **url_kwargs) }}
    </div>
    {% endif %}
    <table id="cancel-attention-user-info-table" class="table table-bordered table-hover table-condensed table-striped">
        <thead>
            <tr>
                <th>用户ID</th>
                <th>工程商</th>
                <th>电话</th>
                <th>城市</th>
                <th>首次发送短信日期</th>
                <th>当前绑定状况</th>
                <th>推送订单次数</th>
                <th>进站次数</th>
                <th>点击抢单次数</th>
                <th>点击立即关注次数</th>
                <th>是否正在营销</th>
            </tr>
        </thead>
        <tbody>

            {% for i in records %}

            <tr>
                <td>{{ i.user_id }}</td>
                <td>
                    <a
                            href="{{ url_for('op_bp.user_info', user_id=i.user_id, list_key='July') }}"
                            name="user-info"
                            target="_blank">
                        {{ i.nickname }}
                    </a>
                </td>
                <td>{{ i.mobile | encrypt }} </td>
                <td>{{ i.city }}</td>
                <td>{{ i.first_send_date }}</td>
                <td>{% if i.wx_openid %}是{% else %}否{% endif %}</td>
                <td>{{ i.total_send_count or 0 }}</td>
                <td>{{ i.view_count or 0}}</td>
                <td>{{ i.bid_click_count or 0 }}</td>
                <td>{{ i.attend_click_count or 0 }}</td>
                <td>{% if i.status==10 %}是{% else %}否{% endif %}</td>
            </tr>

        {% endfor %}
        </tbody>
    </table>

    {% if pagination %}
    <div class="pagination">
        {{ macros.pagination_widget(pagination, 'op_bp.invite_users', list_key='July', **url_kwargs) }}
    </div>
    {% endif %}

{% endblock %}

{% block scripts %}
    {{ super() }}
    <script>
        $(document).ready(function () {
            $("#export-user-info").click(function () {
                var url = '{{ url_for('op_bp.export_invite_users_list', list_key='July') }}';
                url = url + '?' + 'send_date_begin=' + $('#send_date_begin').val() +
                    '&send_date_end=' + $('#send_date_end').val() +
                    '&status=' + $('#status').val();
                if ($('#is_bind').is(':checked')) {
                    url = url + '&is_bind=1'
                }
                window.location.href = url;
            });
        })
    </script>
{% endblock %}
